/// **************************************************************************************************
/// "Copyright (c) 2007 Sai Panyam, Inc.  All rights reserved."
/// **************************************************************************************************
/// Component Name   :	AlignmentCollection, Member of System72.NTextile 
/// Description      :	AlignmentCollection description
/// Author           :	Sai Panyam
/// Creation Date    :	November 09 2007
/// Modified Date    :              
/// Modified By      :
/// **************************************************************************************************
using System.Collections.Generic;

namespace System72.NTextile
{
    public class AlignmentCollection : List<Alignment>
    {
        #region Private Variables

        private Alignment m_alignmentToMatch;

        #endregion

        #region Public Methods
        /// <summary>
        /// 
        /// </summary>
        /// <param name="alignOperator"></param>
        /// <returns></returns>
        public Alignment GetAlignmentByOperator(string alignOperator)
        {
            Alignment found=null;
            foreach (Alignment alignment in this)
            {
                if(alignment.Operator==alignOperator)
                {
                    found = alignment;
                    break;
                }
            }
            return found;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="alignment"></param>
        /// <returns></returns>
        public bool ContainsAlignment(Alignment alignment)
        {
            if (alignment != null)
            {
                m_alignmentToMatch = alignment;
                return Exists(alignmentSearchPredicate);
            }
            else
            {
                return false;
            }
        }
        #endregion

        #region Private Method
        /// <summary>
        /// 
        /// </summary>
        /// <param name="matchAlignment"></param>
        /// <returns></returns>
        private bool alignmentSearchPredicate(Alignment matchAlignment)
        {
            if (matchAlignment != null)
            {
                if (matchAlignment.AlignmentType == m_alignmentToMatch.AlignmentType)
                {
                    return true;
                }
            }
            return false;
        }

        #endregion
    }
}